package com.itheima.edu.info.manager.ceshi;

import java.io.*;
import java.text.DecimalFormat;
import java.util.UUID;

public class ThreadTest implements Runnable{
    File file;
    File file2;

    public ThreadTest() {
    }

    public ThreadTest(File file, File file2) {
        this.file = file;
        this.file2 = file2;
    }

    @Override
    public void run() {

        try {
            InputStream is=new FileInputStream(file);
            int a;
            float cunot=0.0F;
            int b=0;
            byte []arr=new byte[1024];
            UUID uuid = UUID.randomUUID();
            OutputStream os=new FileOutputStream(file2);
            while ((a=is.read(arr))!=-1){
                cunot+=a;
                os.write(arr,0,a);
                DecimalFormat df = new DecimalFormat("##.#%");
                String format = df.format(cunot /file.length());//72540
                System.out.println(uuid+"写入"+format);
            }
            System.out.println("-------------------------------");
         System.out.println(file.length());



        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
